﻿using IterationLife.Educations.Models;
using Util.Datas.Ef;

namespace IterationLife.Datas.Mappings.Educations {
    /// <summary>
    /// 课程大纲映射配置
    /// </summary>
    public class SyllabusMap : AggregateRootMapBase<Syllabus> {
        /// <summary>
        /// 映射表
        /// </summary>
        protected override void MapTable() {
            ToTable( "Syllabuses", "Educations" );
        }
        
        /// <summary>
        /// 映射属性
        /// </summary>
        protected override void MapProperties() {
            //课程大纲编号
            Property(t => t.Id)
                .HasColumnName("SyllabusId");
        }
        
        /// <summary>
        /// 映射导航属性
        /// </summary>
        protected override void MapAssociations() {
            //内容资源
            HasOptional(t => t.ContentResource)
                .WithMany()
                .HasForeignKey(d => d.ContentResourceId);
            //教材
            HasOptional(t => t.TextBook)
                .WithMany(t => t.Syllabuses)
                .HasForeignKey(d => d.TextBookId);
        }
    }
}